const mongoose = require('mongoose')

const Schema = mongoose.Schema
const Types = Schema.Types

const Task = new Schema({
  id: Types.ObjectId,
  bid: { // epubee中的bookid
    type: Types.String,
    required: true
  },
  cover: Types.String, // 书籍封面
  title: { // 书名
    type: Types.String,
    required: true,
    index: 1
  },
  userid: { // 任务发起者id
    type: Types.String,
    required: true,
    index: 1
  },
  author: Types.String, // 作者
  createTime: { // 任务添加时间
    type: Types.Date,
    default: Date.now,
    index: 1
  }
})

// module.exports = {
//   name: 'Task',
//   schema: Task
// }

module.exports = mongoose.model('Task', Task)
